package com.xiaoshuidi.cloud.module.rooms.api.roomhouse;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.rooms.api.roomhouse.vo.FreezeRepairReqVO;
import com.xiaoshuidi.cloud.module.rooms.api.roomhouse.vo.RoomHouseFilingsResp;
import com.xiaoshuidi.cloud.module.rooms.api.roomhouse.vo.RoomHouseMonthRentalDto;
import com.xiaoshuidi.cloud.module.rooms.api.roomhouse.vo.UpdateContractInfoByRenewalReqVO;
import com.xiaoshuidi.cloud.module.rooms.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.rooms.vo.RoomHouseReserveVo;
import com.xiaoshuidi.cloud.module.rooms.vo.RoomHouseRespVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author hans.zhang
 */
@FeignClient(name = ApiConstants.SERVERNAME)
@Tag(name = "RPC接口 - 房源相关接口")
public interface RoomHouseApi {

    String PREFIX = ApiConstants.PREFIX + "/roomhouse";

    @Operation(summary = "房源报修 - 完成")
    @Parameter(name = "roomHouseId", description = "房源(房间)id")
    @PostMapping(PREFIX + "/repairfinish")
    public CommonResult<Boolean> repairFinish(@RequestParam("roomHouseId") Long roomHouseId);


    @Operation(summary = "根据id列表获取房间信息")
    @Parameters({
            @Parameter(name = "ids", description = "id列表"),
    })
    @GetMapping(PREFIX + "/getroomhousebyids")
    public CommonResult<List<RoomHouseRespVo>> getRoomHouseByIds(@RequestParam("ids") List<Long> ids);

    @Operation(summary = "获取房源信息")
    @Parameter(name = "roomHouseId", description = "房源(房间)id")
    @GetMapping(PREFIX + "/getroomhouseinfobyid")
    public CommonResult<RoomHouseRespVo> getRoomHouseinfoById(@RequestParam("roomHouseId") Long roomHouseId);

    @Operation(summary = "获取房源信息")
    @Parameter(name = "roomHouseAddr", description = "房间地址")
    @Parameter(name = "apartmentId", description = "公寓编号")
    @GetMapping(PREFIX + "/queryByAddr")
    CommonResult<RoomHouseRespVo> queryByAddr(@RequestParam("roomHouseAddr")String roomHouseAddr,@RequestParam("apartmentId")Long apartmentId);

    @Operation(summary = "根据房源ID获取定价")
    @Parameter(name = "ids", description = "房源(房间)id")
    @GetMapping(PREFIX + "/list-month-rental")
    CommonResult<List<RoomHouseMonthRentalDto>> listMonthRental(@RequestParam("ids") @NotNull List<Long> ids);

    @Operation(summary = "冻结部门下的所有房源")
    @Parameters({
            @Parameter(name = "deptId", description = "部门Id"),
    })
    @PostMapping(PREFIX + "/room-freeze-by-deptId")
    public CommonResult<Boolean> roomFreezeByDeptId(@RequestParam("deptId") Long deptId);

    @Operation(summary = "解冻部门下的所有房源")
    @Parameters({
            @Parameter(name = "roomHouseId", description = "房源id"),
    })
    @PostMapping(PREFIX + "/room-un-freeze-by-deptId")
    public CommonResult<Boolean> roomUnFreezeByDeptId(@RequestParam("deptId") Long deptId);

    @Operation(summary = "房间冻结")
    @Parameters({
            @Parameter(name = "roomHouseId", description = "房源id"),
    })
    @PostMapping(PREFIX + "/roomfreeze")
    public CommonResult<Long> roomFreeze(@RequestBody FreezeRepairReqVO freezeRepairReqVO);

    @Operation(summary = "房间解冻")
    @Parameters({
            @Parameter(name = "roomHouseId", description = "房源id"),
    })
    @PostMapping(PREFIX + "/roomunfreeze")
    public CommonResult<Long> roomUnFreeze(@RequestBody FreezeRepairReqVO freezeRepairReqVO);

    @Operation(summary = "获取房源备案信息")
    @Parameters({
            @Parameter(name = "roomHouseId", description = "房源id"),
    })
    @PostMapping(PREFIX + "/get-filings-room-id")
    CommonResult<RoomHouseFilingsResp> getFilingsByRoomId(@RequestParam("roomHouseId") Long roomHouseId);

    @Operation(summary = "续租合同账单支付后,更新房源的续租合同信息")
    @PostMapping(PREFIX + "/update-contract-info-by-renewal")
    CommonResult<Boolean> updateContractInfoByRenewal(@RequestBody UpdateContractInfoByRenewalReqVO reqVO);

    @Operation(summary = "根据房间id列表更新es房源数据")
    @PostMapping(PREFIX + "/update-es-room-by-ids")
    public CommonResult<Boolean> updateESRoomByIds(@RequestParam("ids") List<Long> ids);

    @Operation(summary = "根据id列表获取房间户型和基本信息")
    @Parameters({
            @Parameter(name = "ids", description = "id列表"),
    })
    @GetMapping(PREFIX + "/getRoomHouseAndLayoutByIds")
    public CommonResult<List<RoomHouseRespVo>> getRoomHouseAndLayoutByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping(PREFIX + "/getRoomHouseReserve")
    public CommonResult<List<RoomHouseReserveVo>> getRoomHouseReserve(@RequestParam("checkInDate") String checkInDate,
                                                                      @RequestParam("checkInDate") Long apartmentId);
}
